package io.renren.modules.app.controller;


import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.UserFocus;
import io.renren.modules.app.service.UserFocusService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 用户关注表
 *
 * @author chenjiacheng
 * @email 
 * @date 2019-02-11 19:04:11
 */
@RestController
@RequestMapping("app/userfocus")
public class UserFocusController {
    @Autowired
    private UserFocusService userFocusService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("app:userfocus:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userFocusService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userId}")
    @RequiresPermissions("app:userfocus:info")
    public R info(@PathVariable("userId") Integer userId){
			UserFocus userFocus = userFocusService.selectById(userId);

        return R.ok().put("userFocus", userFocus);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("app:userfocus:save")
    public R save(@RequestBody UserFocus userFocus){
			userFocusService.insert(userFocus);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("app:userfocus:update")
    public R update(@RequestBody UserFocus userFocus){
			userFocusService.updateById(userFocus);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("app:userfocus:delete")
    public R delete(@RequestBody Integer[] userIds){
			userFocusService.deleteBatchIds(Arrays.asList(userIds));

        return R.ok();
    }

}
